package com.fei.controller;

import com.fei.bean.CommentBean;
import com.fei.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

@Controller
public class CommentController {

    @Autowired
    CommentService commentService;

    @RequestMapping("/admin/toComment")
    public String toComment(int id, Model model){
        List<CommentBean> commentBeans = commentService.selectOneVideoIdService(id);
        model.addAttribute("commentBeans",commentBeans);
        model.addAttribute("video_id",id);
        return "comment";
    }

//    删除评论
    @RequestMapping("/admin/delete/deleteComment")
    public String deleteComment(int id,int video_id,Model model){
        commentService.deleteOneIdService(id);
        return "redirect:/admin/toComment?id="+video_id;
    }

}
